package com.ruoyi.web.controller.dgw;

import java.util.List;
import java.util.Map;

import com.ruoyi.dgw.domain.TagNumber;
import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dgw.domain.TableEarnumber;
import com.ruoyi.dgw.service.ITableEarnumberService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 耳标数量Controller
 * 
 * @author ruoyi
 * @date 2021-11-22
 */
@RestController
@RequestMapping("/dgw/earnumber")

public class TableEarnumberController extends BaseController
{
    @Autowired
    private ITableEarnumberService tableEarnumberService;

    /**
     * 查询耳标数量列表
     */
    @PreAuthorize("@ss.hasPermi('dgw:earnumber:list')")
    @GetMapping("/list")
    public TableDataInfo list(TableEarnumber tableEarnumber)
    {
        startPage();
        List<TableEarnumber> list = tableEarnumberService.selectTableEarnumberList(tableEarnumber);
        return getDataTable(list);
    }

    /**
     * 导出耳标数量列表
     */
    @PreAuthorize("@ss.hasPermi('dgw:earnumber:export')")
    @Log(title = "耳标数量", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TableEarnumber tableEarnumber)
    {
        List<TableEarnumber> list = tableEarnumberService.selectTableEarnumberList(tableEarnumber);
        ExcelUtil<TableEarnumber> util = new ExcelUtil<TableEarnumber>(TableEarnumber.class);
        return util.exportExcel(list, "耳标数量数据");
    }

    /**
     * 获取耳标数量详细信息
     */
    @PreAuthorize("@ss.hasPermi('dgw:earnumber:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tableEarnumberService.selectTableEarnumberById(id));
    }

    /**
     * 新增耳标数量
     */
    @PreAuthorize("@ss.hasPermi('dgw:earnumber:add')")
    @Log(title = "耳标数量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TableEarnumber tableEarnumber)
    {
        return toAjax(tableEarnumberService.insertTableEarnumber(tableEarnumber));
    }

    /**
     * 修改耳标数量
     */
    @PreAuthorize("@ss.hasPermi('dgw:earnumber:edit')")
    @Log(title = "耳标数量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TableEarnumber tableEarnumber)
    {
        return toAjax(tableEarnumberService.updateTableEarnumber(tableEarnumber));
    }

    /**
     * 删除耳标数量
     */
    @PreAuthorize("@ss.hasPermi('dgw:earnumber:remove')")
    @Log(title = "耳标数量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tableEarnumberService.deleteTableEarnumberByIds(ids));
    }


    @GetMapping("/queryList")
    public TableDataInfo queryList(String village){
        startPage();
        List<Map<String,String>> list =  tableEarnumberService.queryList(village);
        return getDataTable(list);
    }

    @GetMapping("/querySum")
    public AjaxResult querySum(Long deptId){
        logger.info("地区：{}",deptId);
        Map<String,String> list =  tableEarnumberService.querySum(deptId);
        return AjaxResult.success(list);
    };
    @GetMapping("/queryEarList")
    public TableDataInfo queryEarList(String name, String deptName, String phone){
        startPage();
        List<TagNumber> list = tableEarnumberService.queryEarList(name, deptName, phone);
        return getDataTable(list);
    }
}

